<template>
    <c-list-template :operation="true" title="进口商客户管理">
        <template slot="search">
            <el-row :gutter="24">
                <el-col :span="6" class="flex-center">
                    <div class="mr-lg">进口商公司名称</div>
                    <el-input placeholder="请输入进口商公司名称" v-model="querys.importerName" class="wh flex-1 mr-lg" />
                </el-col>
                <el-col :span="18" class="flex-x-end">
                    <el-button icon="el-icon-search" type="primary" @click="handleSearch">搜索</el-button>
                    <el-button icon="el-icon-delete" @click="handleReset">重置</el-button>
                </el-col>
            </el-row>
        </template>
        <template slot="list">
            <el-table :header-cell-style='{ background: "#F1F1F1", color:"#092132",height:"58px" }' :row-style='{height:"58px"}' :data="tableData" v-loading="loading">
                <el-table-column align="center" type="index" label="序号" width="80"></el-table-column>
                <el-table-column align="center" prop="name" label="进口商公司名称" width=""></el-table-column>
                <el-table-column align="center" prop="email" label="邮箱" width=""></el-table-column>
                <el-table-column align="center" label="创建时间">
                    <template slot-scope="scope">
                        <span>{{ scope.row.timeCreate | dateYMDHMSFormat }}</span>
                    </template>
                </el-table-column>
                <el-table-column align="center" label="状态">
                    <template slot-scope="scope">
                        <div :class='"statusDot status_"+scope.row.authStatus'></div>{{ authStatusList[scope.row.authStatus].label }}
                    </template>
                </el-table-column>
                <el-table-column align="center" label="操作" width="">
                    <template slot-scope="scope">
                        <el-link type="primary" class="mr-lg" @click="handleDetails(scope.row,true,false)" v-if="scope.row.authStatus == 1">审核</el-link>
                        <el-link type="primary" class="mr-lg" @click="handleDetails(scope.row,false,true)" v-else>详情</el-link>
                    </template>
                </el-table-column>
            </el-table>
        </template>
        <template slot="pagination">
            <el-pagination background :current-page="querys.current" :page-sizes="[10, 20, 50, 100]" :page-size="querys.size" layout="total, sizes, prev, pager, next, jumper" :total="total" @size-change="handleSizeChange" @current-change="handleCurrentChange" />
        </template>

    </c-list-template>
</template>

<script>
import { authStatus } from "@/utils/status";
export default {
    components: {

    },
    data () {
        return {
            querys: {
                size: 10,
                current: 1
            },
            loading: false,
            tableData: [],
            total: 0,
            authStatusList: authStatus
        };
    },
    mounted () {
        this.tableList();
    },
    methods: {
        handleSearch () {
            this.querys.current = 1;
            this.tableList();
        },
        handleReset () {
            this.querys = {
                mobile: "",
                name: "",
                current: 1,
                size: 10,
            };
            this.getList();
        },

        handleSizeChange (val) {
            this.querys.size = val;
            this.tableList();
        },
        handleCurrentChange (val) {
            this.querys.current = val;
            this.tableList();
        },
        handleDetails (item, isView) {
            this.$router.push({
                path: "/custom/importer/details",
                query: {
                    isView: isView,
                    id: item.id
                },
            });
        },
        tableList () {
            this.loading = true;
            const params = JSON.parse(JSON.stringify(this.querys));
            const url = "/buyerInfo/page";
            this.$get({ url, params }).then((res) => {
                this.tableData = res.records
                this.loading = false;
            });
        }
    }
};
</script>
<style scoped lang="scss">
</style>
